package com.yilian.xlmusic.android.utils;

import android.animation.ObjectAnimator;
import android.view.View;

public class ViewAnimator {
    /**
     *
     * @param view 需要动画的View
     * @param po 需要X轴动画传 width，Y轴同理 height
     * @param StartValue 起始位置
     * @param endValue  目标位置
     */
    public static void doAnim(View view, String po, int StartValue, int endValue) {
        ViewWrapper viewWrapper = new ViewWrapper(view);
        ObjectAnimator.ofInt(viewWrapper, po, StartValue, endValue).setDuration(100).start();
    }

    public static class ViewWrapper {

        private View rView;

        public ViewWrapper(View target) {
            rView = target;
        }

        public int getWidth() {
            return rView.getLayoutParams().width;
        }

        public void setWidth(int width) {
            rView.getLayoutParams().width = width;
            rView.requestLayout();
        }

        public int getHeight() {
            return rView.getLayoutParams().height;
        }

        public void setHeight(int height) {
            rView.getLayoutParams().height = height;
            rView.requestLayout();
        }
    }
}
